﻿Public Class frmTableSingleSearch

    Dim strNameForm As String = "Search "
    Dim oTableSingleInfo As Data.TableSingleInfo
    Public strSqlWhere As String = " 1=1 "

    Public Function Initialize(ByRef inTableSingleInfo As Data.TableSingleInfo) As Boolean
        Try
            strNameForm &= inTableSingleInfo.strNameForm
            Me.Text = strNameForm
            oTableSingleInfo = inTableSingleInfo

            Return True
        Catch ex As Exception
            Base.ShowError.Show("Initialize", Me.Name, "Initialize", ex)
            Return False
        End Try
    End Function

#Region "Commands"

    Private Sub cmdCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCancel.Click
        Me.DialogResult = Windows.Forms.DialogResult.Cancel
    End Sub

    Private Sub cmdSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSearch.Click
        Try
            strSqlWhere = String.Format("Name like '{0}%'", txtName.Text)
            Me.DialogResult = DialogResult.OK
        Catch ex As Exception
            Base.ShowError.Show("Search", Me.Name, "cmdSearch_Click", ex)
        End Try
    End Sub

#End Region

#Region "Form events"

    Private Sub Me_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        If e.KeyCode = Keys.Escape Then
            Me.DialogResult = DialogResult.Cancel
        End If
    End Sub

#End Region

End Class